/* Apaga categoria */
package servlets;

import java.sql.*;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.jasper.tagplugins.jstl.core.Out;

import beans.Categoria;

import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;

import dbclass.AutorDAO;
import dbclass.AutorJDBC;
import dbclass.CategoriaDAO;
import dbclass.CategoriaJDBC;
import dbclass.NoticiaDAO;
import dbclass.NoticiaJDBC; 

/**
 * Servlet implementation class Autores
 */
public class CategoriasDelete extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public CategoriasDelete() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession(true);
		//Verifica login
		if(session.getValue("autor_login") == null) {
			response.sendRedirect("Home?msg_erro=Acesso Negado");  return;
		} 
		
		String url = null;
		
		CategoriaDAO categoriaDAO = new CategoriaJDBC();
		
		int id = Integer.parseInt(request.getParameter("id"));

//		try {
//				
//			if(categoriaDAO.delete(id)) {
//				 url="Categorias?msg_sucesso=Categoria apagada com sucesso";  
//			}
//			else {
//				url="Categorias?msg_erro=Algum erro ocorreu ao apagar a categoria"; 
//			}  
//			response.sendRedirect(url);
//		} catch (ClassNotFoundException e) {  
//			// TODO Auto-generated catch block 
//			e.printStackTrace();
//		} catch (SQLException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
	
		
 
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
